﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QLNhaThuoc.DTO
{
    class ThuocLowStockState:ThuocState
    {
        public ThuocLowStockState(ThuocState state)
        {
            _soLuong = state.SoLuong;
            _thuoc = state.Thuoc;
        }

        public override int Sell(int sellQuantity)
        {
            if(sellQuantity >= _soLuong)
            {
                sellQuantity = _soLuong;
                _soLuong -= sellQuantity;
            }
            else
            {
                _thuoc.State = new ThuocNormalStockState(this);
                sellQuantity = _thuoc.Sell(sellQuantity);
            }

            return sellQuantity;
        }

        public override void Restock(int restockQuantity)
        {
            _soLuong += restockQuantity;
            _thuoc.State = new ThuocNormalStockState(this);
        }
    }
}
